package com.nb.controller;

import com.nb.DTO.*;
import jakarta.annotation.Resource;
import com.nb.service.LawyerManagerService;
import com.nb.result.Result;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/lawyer")
public class LawyerManagerController {

    @Resource
    private LawyerManagerService lawyerManagerService;


    @GetMapping("/info/{lawyerId}")
    public Result getLawyerInfo(@PathVariable Long lawyerId) {
        return Result.success(lawyerManagerService.getLawyerInfo(lawyerId));
    }

    @PutMapping("/info")
    public Result updateLawyerInfo(@Validated @RequestBody LawyerInfoDTO infoDTO) {
        lawyerManagerService.updateLawyerInfo(infoDTO);
        return Result.success("律师信息更新成功");
    }

    @GetMapping("/performance/{lawyerId}")
    public Result getPerformance(@PathVariable Long lawyerId) {
        return Result.success(lawyerManagerService.getLawyerPerformance(lawyerId));
    }

    @GetMapping("/performance/list")
    public Result listPerformance() {
        return Result.success(lawyerManagerService.listLawyerPerformance());
    }

    @PostMapping("/assign")
    public Result assignCaseToLawyer(@Validated @RequestBody CaseAssignDTO assignDTO) {
        lawyerManagerService.assignCase(assignDTO);
        return Result.success("案件分派成功");
    }


    @GetMapping("/search")
    public Result searchLawyers(LawyerSearchDTO searchDTO) {
        return Result.success(lawyerManagerService.searchLawyers(searchDTO));
    }

}